<div class="modal-head">
  <h2><%= @project ? "Edit Permission #{message("projects_role.#{@role}")} For: " + h(@project.name) : "Edit Global Permission: #{message("global_permissions.#{@role}")}" -%></h2>
</div>

<div class="modal-body">
  <div id="select-users-permissions"></div>
</div>

<div class="modal-foot">
  <a href="#" onclick="window.location.reload();return false" id="cancel-update-permission-users"><%= h message('close') -%></a>
</div>

<script>
  var selectList = new SelectList({
    el: '#select-users-permissions',
    width: '100%',
    format: function (item) { return item.name; },
    searchUrl: baseUrl + '/permissions/search_groups?permission=<%= @role -%><%= @project ? "&component=" + @project.key : "" -%>',
    selectUrl: baseUrl + '/api/permissions/add',
    deselectUrl: baseUrl + '/api/permissions/remove',
    extra: {
      permission: '<%= @role -%>'
      <%= @project ? ", component: '" + @project.key + "'" : "" %>
    },
    selectParameter: 'group',
    selectParameterValue: 'name',
    labels: {
      selected: 'With',
      deselected: 'Without',
      all: 'All'
    },
    tooltips: {
      select: 'Click to grant the permission to the group',
      deselect: 'Click to revoke the permission from the group'
    }
  });
</script>
